<?php
/**
 * sku
 * User: lyl
 * Date: 2019-04-29
 */

namespace Biz\module\Classes\WikiClean;

class Sku
{
    /**
     * 执行统一操作
     **/
    public static function run($params, &$data){
        self::_add($params, $data);
    }

    /**
     * 插入表
     **/
    private static function _add($params, &$data){
        $source_data = json_decode($params['source_data'], true);

        if(!empty($source_data['product_sku_detail'])){
            foreach($source_data['product_sku_detail'] as $_k=>&$_v){
                $data['sku'][$_k] = [
                    'name'=> $_v['sku_name'],
                    'price'=> isset($_v['sku_price'])?$_v['sku_price']:0,
                    'stock'=> isset($_v['sku_stock'])?$_v['sku_stock']:0,
                    'desc'=> isset($_v['sku_name'])?$_v['sku_name']:'',
                ];
            }
        }
    }

}